package com.example.xiaoxueqixiangmu.jiemian;


import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.xiaoxueqixiangmu.R;

import java.util.ArrayList;
import java.util.HashMap;

public class MyListViewAdapter2 extends BaseAdapter {
    private Context context;
    private ArrayList<HashMap<String,String>> dataArray;

    public MyListViewAdapter2(Context context, ArrayList<HashMap<String, String>> dataArray) {
        this.context = context;
        this.dataArray = dataArray;
    }

    private static final String TAG = "MyListViewAdapter2";
    @Override
    public int getCount() {
        return dataArray.size();
    }

    @Override
    public Object getItem(int position) {
        return dataArray.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        View item = layoutInflater.inflate(R.layout.item_ticket, null, false);

        TextView txtSeatName , txtPrice , txtSeatNum , txtBook;
        txtSeatName = item.findViewById(R.id.txtSeatName);
        txtPrice = item.findViewById(R.id.txtPrice);
        txtBook = item.findViewById(R.id.txtBook);
        txtSeatNum = item.findViewById(R.id.txtSeatNum);

        HashMap<String, String> hashMap = dataArray.get(position);

        txtSeatName.setText(hashMap.get("seatName"));
        txtPrice.setText(hashMap.get("price"));
        txtBook.setText(hashMap.get("book"));
        txtSeatNum.setText(hashMap.get("seatNum"));
        txtBook.setText("预定");

        return item;
    }
}
